package com.atguigu.servlet;

import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

/**
 * 1、实利化 构造器
 * 2、初始化 init
 * 3、服务 service
 * 4、销毁 destory
 */
@WebServlet(value = "/test",loadOnStartup = 1) //如果想服务器启动就加载该方法需要设置属性loadOnStartup   -1是不会初始化 放其他正整数就是服务器启动就实利化
public class ServletTest1  extends HttpServlet {
    public ServletTest1() {
        System.out.println("ServletTest1 构造器方法");
    }
    @Override
    public void init() throws ServletException {
        System.out.println("初始化");
    }
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("服务");
    }

    @Override
    public void destroy() {
        System.out.println("销毁！");
    }
}
